Code review for statisticians, data scientists, & modellers

Dr Jack Kennedy (he/him)

Infectious disease modelling team | UKHSA

I’m Jack, it’s nice to meet you 👋



  statistics PhD, education, & consultancy

  data scientist & infectious disease modeller

  bit of git nerd

  I mostly work in R, concepts are language-agnostic

Who is this talk for?



🎓 a big chunk of my team have an academic background

👩‍💻 we spend a lot of time developing software …

📊 … but we’re in analytical roles

🤫 honestly? This talk is for me

It’s a balancing act

Have you ever …



👩‍💻   submitted a pull request?

🔍   performed a code review?

🤔   thought about how to do code review better?

vote with 👍 and 👎 emojis

Literal code review



📝 write some comments

💻 run the code

🔧 make direct suggestions

👀 let’s review some code

Why review code?



✔️ quality & compliance

💡 provide ideas for improving the code

🧠 knowledge transfer

🚌 increase your bus number!

What is a reviewer looking for?



🐛 potential bugs

📈 quality of outputs

🔢 check the mathematics and statistics

💼 sensitive information!

How should a reviewer behave?



❤️ be kind and praise your team members

☕ take a break if you’re getting grumpy

❓ ask open ended questions about the code

🤖 automate the painful stuff: linters, stylers, CI/CD

Code is never perfect



🩺 accept PRs when overall health is improved

☎️ have a natter about the code

🛠️ favour maintainable and readable code

👪 broaden the discussion

Triage your suggestions



🕷️ Nit: this is minor; I am being pedantic

🤔 Consider: I’m not too bothered, would be nice

🤷 FYI: out of scope, I think you’d like this approach

⚠️ Should: an essential fix!

Every team is unique



📰 come up with your own team code review style

📣 agree on the style as a team activity

♻️ trial it, review it, adapt it

🖊️ document your process (use a wiki!)

Some thoughts on best practices

best practices are always changing



🤔 come up with a sensible approach

🖊️ document it, shout about it, adapt it

🎯 apply the rules consistently

🤷 anything else is just an opinion

why adopt best practices?



⛵ we run a tight ship

😩 decision fatigue

💎 clarity leads to productivity

🤷 maybe they should be called standard practices

In review



🔑 code review is key to quality outputs

👪 we all need to be reviewing code

👏 be kind, supportive and encouraging

⏩ keep code moving forward

Further resources

Keep in touch 🖊️



@_jcken@fossoton.org

Connect with me!

Chat on Gov DS

Maybe see you at a north-east tech meetup?

Questions, comments, thoughts?

Bonus content

well done for getting this far …